<template>
  <el-dialog
      :visible.sync="visible"
      width="850px"
      :before-close="onClose">
      <div slot="title" style="font-size: 14px;font-weight: 500;">
        新托管企微号群聊分配设置
      </div>
      <div class="deposit-dialog-main">
        <el-form :model="form" status-icon ref="form" label-width="140px" label-position="left" class="demo-ruleForm">
          <el-form-item label="企微号：" prop="pass">
            <span>所有新托管的企微号</span>
          </el-form-item>
          <el-form-item label="是否分配：" prop="type">
            <el-radio-group v-model="form.type">
              <el-radio :label="1">全部群</el-radio>
              <el-radio :label="2">部门群</el-radio>
              <el-radio :label="3">不设置</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="选择现有群：" prop="pass">
            <span>新号托管后手动选择现有群</span>
          </el-form-item>
          <el-form-item label="符合条件的新群：" prop="pass">
            <span><el-switch v-model="isChecked" disabled size="small" /> 加入新群满5分钟判断，符合条件的群自动加入分发</span>
            <div class="card-body" v-if="form.type === 2">
              <el-form :model="ruleForm" status-icon ref="ruleForm" label-width="140px" label-position="right">
                <el-form-item label="关键词：" prop="pass">
                  <div class="form-item-rows">
                    <el-select size="small" style="width: 128px;">
                    <el-option
                      v-for="item in keyWords"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id">
                    </el-option>
                  </el-select>
                  <el-input placeholder="请输入内容" v-model="ruleForm.keyWord" size="small" style="width: 240px;">
                    <template slot="append">
                      <i class="el-icon-plus"></i>
                    </template>
                  </el-input>
                  </div>
                </el-form-item>
                <el-form-item label="群标签：" prop="type">
                  <div class="form-item-rows">
                    <el-select size="small" style="width: 128px;">
                      <el-option
                        v-for="item in keyTags"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id">
                      </el-option>
                  </el-select>
                  <el-select size="small" v-model="ruleForm.tags" placeholder="请选择" style="width: 240px;">
                    <el-option
                      v-for="item in keyTags"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id">
                    </el-option>
                  </el-select>
                  </div>
                </el-form-item>
                <el-form-item size="small" label="是否群主/管理：" prop="pass">
                  <el-select v-model="ruleForm.tags" placeholder="请选择" style="width: 375px;">
                    <el-option
                      v-for="item in leader"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="建群时间：" prop="pass">
                  <el-date-picker
                    size="small"
                    style="width: 375px;"
                    v-model="ruleForm.datetime"
                    type="daterange"
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期">
                  </el-date-picker>
                </el-form-item>
                <div class="exclude-options">
                  <el-checkbox v-model="isexclude" /><span style="margin-left: 8px;">排除符合以下条件的客户群</span>
                </div>
                <div v-if="isexclude">
                  <el-form-item label="关键词：" prop="pass">
                    <div class="form-item-rows">
                      <el-select size="small" style="width: 128px;">
                      <el-option
                        v-for="item in keyWords"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id">
                      </el-option>
                    </el-select>
                    <el-input placeholder="请输入内容" v-model="ruleForm.keyWord" size="small" style="width: 240px;">
                      <template slot="append">
                        <i class="el-icon-plus"></i>
                      </template>
                    </el-input>
                    </div>
                  </el-form-item>
                  <el-form-item label="群标签：" prop="type">
                    <div class="form-item-rows">
                      <el-select size="small" style="width: 128px;">
                        <el-option
                          v-for="item in keyTags"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id">
                        </el-option>
                    </el-select>
                    <el-select size="small" v-model="ruleForm.tags" placeholder="请选择" style="width: 240px;">
                      <el-option
                        v-for="item in keyTags"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id">
                      </el-option>
                    </el-select>
                    </div>
                  </el-form-item>
                  <el-form-item size="small" label="是否群主/管理：" prop="pass">
                    <el-select v-model="ruleForm.tags" placeholder="请选择" style="width: 375px;">
                      <el-option
                        v-for="item in leader"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id">
                      </el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="建群时间：" prop="pass">
                    <el-date-picker
                      size="small"
                      style="width: 375px;"
                      v-model="ruleForm.datetime"
                      type="daterange"
                      range-separator="至"
                      start-placeholder="开始日期"
                      end-placeholder="结束日期">
                    </el-date-picker>
                  </el-form-item>
                </div>
              </el-form>
            </div>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="onClose">取消</el-button>
        <el-button type="primary" @click="onClose">确定</el-button>
      </span>
    </el-dialog>
</template>
<script>
export default {
  data() {
    return {
      form: {
        type: 1,
        isDistribute: 0
      },
      ruleForm: {
        keyWord: ''
      },
      isexclude: false,
      typeIndex: 1,
      isChecked: true,
      types: [
        { id: 1, title: '私聊+群聊'},
        { id: 2, title: '私聊'},
        { id: 3, title: '群聊'},
      ],
      keyWords: [
        {id: 1, name: '含任意关键词'},
        {id: 2, name: '含所有关键词'},
      ],
      keyTags: [
        {id: 1, name: '含任意标签'},
        {id: 2, name: '含所有标签'},
        {id: 3, name: '未打任何标签'},
      ],
      leader: [
        {id: 1, name: '群主/群管理员'},
        {id: 2, name: '群主'},
        {id: 3, name: '群成员'},
      ]
    }
  },
  props: ['visible'],
  methods: {
    onClose() {
      this.$emit('handCloseDialog');
    }
  },
}
</script>
<style lang="scss" scoped>
.card-body {
  border: 1px solid #e9e9e9;
  padding: 16px;
  line-height: 22px;
  .form-item-rows {
    display: flex;
    align-items: center;
    column-gap: 8px;
  }
  .exclude-options {
    display: flex;
    align-items: center;
    border-top: 1px solid #e9e9e9;
    font-size: 14px;
    line-height: 22px;
    padding: 16px 0;
    font-weight: 600;
  }
}
::v-deep .el-form-item .el-form-item {
  margin-bottom: 16px;
}
::v-deep .el-input-group__append {
  padding: 0 10px;
}
</style>